package com.woniu.controller;
import com.woniu.entity.Employee;
import com.woniu.service.UserService;
import com.woniu.util.ResponseUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;


@RestController
@RequestMapping("/back")
public class BackLoginController {

    @Resource
    private UserService userService;

    @PostMapping("/login")
    public ResponseUtil login(@RequestBody Map<String, Object> loginInfo) throws Exception {
        // 从请求中获取用户名、密码和验证码信息
        String username = (String) loginInfo.get("username");
        String password = (String) loginInfo.get("password");
        String captchaKey = (String) loginInfo.get("captchaKey");
        String captchaCode = (String) loginInfo.get("captchaCode");

        // 构建Employee对象
        Employee employee = new Employee();
        employee.setUsername(username);
        employee.setPassword(password);
        return userService.backLogin(employee, captchaKey, captchaCode);
    }
}